package com.demo.commonslang3;

import org.apache.commons.lang3.StringUtils;

/**
 * @author wangning
 * @date 2023/12/19 17:04
 * @description isEmpty和isBlank的区别
 *
 * isEmpty仅仅是判断空和长度为0字符串
 * isBlank判断的是空，长度为0，空白字符（包括空格，制表符\t，换行符\n，换页符\f，回车\r）组成的字符串。
 */
public class IsBlankAndIsEmptyTest {
    public static void main(String[] args) {
        System.out.println("StringUtils.isEmpty(null) = " + StringUtils.isEmpty(null));//true
        System.out.println("StringUtils.isEmpty(\"\") = " + StringUtils.isEmpty(""));//true
        System.out.println("StringUtils.isEmpty(\" \") = " + StringUtils.isEmpty(" "));//false
        System.out.println("StringUtils.isEmpty(\"aaa\") = " + StringUtils.isEmpty("aaa"));//false
        System.out.println("StringUtils.isEmpty(\"\\t\") = " + StringUtils.isEmpty("\t"));//false
        System.out.println("StringUtils.isBlank(null) = " + StringUtils.isBlank(null));//true
        System.out.println("StringUtils.isBlank(\"\") = " + StringUtils.isBlank(""));//true
        System.out.println("StringUtils.isBlank(\" \") = " + StringUtils.isBlank(" "));//true
        System.out.println("StringUtils.isBlank(\"aaa\") = " + StringUtils.isBlank("aaa"));//false
        System.out.println("StringUtils.isBlank(\"\\t\") = " + StringUtils.isBlank("\t"));//true

    }
}
